package com.ztesoft.huangfu.learning.springboot.springboottransaction.controller;

import com.ztesoft.huangfu.learning.springboot.springboottransaction.entity.User;
import com.ztesoft.huangfu.learning.springboot.springboottransaction.service.impl.TransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Author: huangfu.daohui
 * Date: 2018/6/8
 * Time: 22:57
 * Version: 1.0
 * Description:
 * https://www.xncoding.com/2017/07/26/spring/sb-transaction.html
 **/
@RestController
public class TransactionControler {
    @Autowired
    private TransactionService transactionService;

    @PostMapping("/errorUpdate")
    public Object first() {
        User user = new User();
        user.setId("1");
        user.setName("admin");
        user.setPassword("admin");
        user.setLoginName("admin");
        transactionService.updateUserError(user);
        return "first controller";
    }

    @PostMapping("/errorUpdate2")
    public Object second() {
        User user = new User();
        user.setId("1");
        user.setName("admin");
        user.setPassword("admin");
        user.setLoginName("admin");
        transactionService.updateUserError(user);
        return "second controller";
    }
}

